﻿using Shp.Web.Models.Contracts;
using Shp.Web.Models.Domain;

namespace Shp.Web.Models.ViewModels
{
    public class CustomerListViewModelBuilder : ICustomerListViewModelBuilder
    {
        #region Fields

        private readonly ICustomerRepository _customerRepository;

        #endregion Fields

        #region Ctors

        public CustomerListViewModelBuilder(ICustomerRepository customerRepository)
        {
            _customerRepository = customerRepository;
        }

        #endregion Ctors

        #region ICustomerListViewModelBuilder Members

        /// <summary>
        /// Prepares and builds the view model.
        /// </summary>
        /// <returns></returns>
        public CustomerListViewModel Build()
        {
            return new CustomerListViewModel
            {
                Customers = _customerRepository.All()
            };
        }
        #endregion
    }
}